package com.wjr.braveheart.http;

import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.Map;

/**
 * description: Http 工具类
 * author: Darren on 2017/10/11 15:36
 * email: 240336124@qq.com
 * version: 1.0
 */
public class Utils {

    /**
     * 解析类上面的泛型
     *
     * @param object
     * @return
     */
    public static Class<?> analysisClazzInfo(Object object) {
        Type genType = object.getClass().getGenericSuperclass();
        Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
        return (Class) params[0];
    }

    public static void closeIo(Closeable closeable) {
        try {
            if (closeable != null)
                closeable.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
